<?php if (!defined("_ECRIRE_INC_VERSION")) return;

require_once(_DIR_PLUGIN_ECATALOGUE.'classes/class.ProductModel.php');

function formulaires_ecatalogue_product_equipment_traiter_dist($id_article) {
    $result = array();
    $result_flag = true;
    
    $mdl = new ProductModel();
    
    $data = array();
    
    if ($id_article_add = _request('id_article_add')) {
        $data['id_equipment'] = _request('id_equipment');
        $result_flag = $mdl->update_by_id($id_article_add, $data, true);    
    }
    
    if ($id_article_delete = _request('id_article_delete')) {
        $data['id_equipment'] = $mdl->GetMaxIdEquipment()+1;
        $result_flag = $mdl->update_by_id($id_article_delete, $data, true);
    }

    if ($result_flag) {
        $result['message_ok'] = _T('ecatalogue:form_saved');
    } else {
        $result['message_erreur'] = _T('ecatalogue:form_error');
    }
    
    set_request('id_article_add');
    set_request('id_article_delete');
    
    return $result;    
}
?>